package com.propertree.mailer.helper;

import java.util.Properties;

import javax.mail.PasswordAuthentication;
import javax.mail.Session;

import com.propertree.mailer.bean.EMailPartyInfo;

public class SessionHelper {

	public static Session createSession(final Properties props,
			final EMailPartyInfo emailPartyInfo) {
		Session session = Session.getInstance(props,
				new javax.mail.Authenticator() {
					protected PasswordAuthentication getPasswordAuthentication() {
						return new PasswordAuthentication(emailPartyInfo
								.getUserName(), emailPartyInfo.getPassword());
					}
				});
		return session;
	}
}
